<template>
  <view>
    <!-- <u-tabbar v-model="current" :list="list" bg-color="#115763" icon-size="50" active-color="#C18659"
      inactive-color="#FFFFFF" :border-top="false" :before-switch="beforeSwitch"></u-tabbar> -->
    <view class="tabbars u-f-ac">
      <view class="items_tab u-f-column u-f-ajc" v-for="(item, index) in list" :key="index" @click="beforeSwitch(index)"
        :class="current === index ? 'actives' : ''">
        <image v-if="current === index" :src="item.iconPath"></image>
        <image v-else :src="item.selectedIconPath"></image>
        <view>{{item.text}}</view>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    props: {
      current: {
        type: Number,
        default: -1
      },
    },
    data() {
      return {
        list: [{
            "selectedIconPath": "/static/images/tabbar/home1.png",
            "iconPath": "/static/images/tabbar/home_active1.png",
            "pagePath": "/pagesD/home/home",
            "text": "首页"
          },
          {
            "selectedIconPath": "/static/images/tabbar/zixun1.png",
            "iconPath": "/static/images/tabbar/zixun_active1.png",
            "pagePath": "/pagesD/media/media",
            "text": "资讯专栏"
          },
          {
            "selectedIconPath": "/static/images/tabbar/qianbao1.png",
            "iconPath": "/static/images/tabbar/qianbao_active1.png",
            "pagePath": "/pagesD/qianbao/qianbao",
            "text": "我的钱包"
          },
          {
            "selectedIconPath": "/static/images/tabbar/mine1.png",
            "iconPath": "/static/images/tabbar/mine_active1.png",
            "pagePath": "/pagesD/member/member",
            "text": "个人中心"
          },
        ],
      }
    },
    mounted() {
      // console.log(this.current)
      // if (this.current != -1) {
      //   this.list[this.current].iconPath = this.list[this.current].selectedIconPath
      // }
    },
    methods: {
      beforeSwitch(index) {
        uni.switchTab({
          url: this.list[index].pagePath
        })
      },
    }
  }
</script>

<style lang="scss">
  .tabbars {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 100rpx;
    background-color: #ffffff ;
	padding-top:10rpx;
    .items_tab {
      width: 25%;
      height: 100%;

      view {
        color: #7f7f80;
        font-size: 24rpx;
        line-height: 1;
        margin-top: 10rpx;
      }

      image {
        width: 40rpx;
        height: 40rpx;
      }
    }

    .actives {
      view {
        color: #001b4d !important;
      }
    }
  }
</style>
